package com.example.pclimb.model;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;

/**
 * 用户点赞记录实体类，用于跟踪用户对攻略的点赞状态
 */
@Entity(tableName = "user_likes", 
        primaryKeys = {"userId", "guideId"},
        foreignKeys = {
            @ForeignKey(entity = User.class,
                    parentColumns = "id",
                    childColumns = "userId",
                    onDelete = ForeignKey.CASCADE),
            @ForeignKey(entity = TravelGuide.class,
                    parentColumns = "id",
                    childColumns = "guideId",
                    onDelete = ForeignKey.CASCADE)
        },
        indices = {
            @Index("userId"),
            @Index("guideId")
        })
public class UserLike {
    private int userId; // 用户ID
    private int guideId; // 攻略ID
    private long likeTime; // 点赞时间戳
    
    public UserLike(int userId, int guideId) {
        this.userId = userId;
        this.guideId = guideId;
        this.likeTime = System.currentTimeMillis();
    }
    
    public int getUserId() {
        return userId;
    }
    
    public void setUserId(int userId) {
        this.userId = userId;
    }
    
    public int getGuideId() {
        return guideId;
    }
    
    public void setGuideId(int guideId) {
        this.guideId = guideId;
    }
    
    public long getLikeTime() {
        return likeTime;
    }
    
    public void setLikeTime(long likeTime) {
        this.likeTime = likeTime;
    }
    
    @NonNull
    @Override
    public String toString() {
        return "UserLike{" +
                "userId=" + userId +
                ", guideId=" + guideId +
                ", likeTime=" + likeTime +
                '}';
    }
} 